from django.urls import path
from . import views
from django.contrib.auth import views as auth_views
from .forms import AuthForm

# 不要重复造轮子，可能还不如别人，把精力放在更有意义的事情上面
SUCCESS_URL = '/success/?msg='
app_name = 'users'
urlpatterns = [
    path('register/', views.register, name = 'register'),
    path('success/', views.success, name = 'success'),
    path('login/', auth_views.LoginView.as_view(
        form_class = AuthForm,
        template_name='form.html',
        extra_context={'title':'登录'}),
         name='login'),
    path('logout/', auth_views.LogoutView.as_view(next_page=SUCCESS_URL+'恭喜你，注销成功！'),name='logout'),
    path('password_change/', auth_views.PasswordChangeView.as_view(
        template_name='form.html',
        success_url =SUCCESS_URL+'恭喜你，密码修改成功！'
     ), name='password_change'),

    path('password_reset/', auth_views.PasswordResetView.as_view(
        template_name='form.html',
        email_template_name='users/password_reset_email.html',
        success_url=SUCCESS_URL+'请登录邮箱完成密码重置'


    ), name='password_reset'),

    path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(
    template_name='form.html',
    success_url = SUCCESS_URL+'密码已重置'

    ), name='password_reset_confirm'),

]

